GitHub Actionsで井戸端プロジェクトのバックアップを取得しReleaseに登録する
普段GitHub Actionsを使わないので、勉強しながら試してみたmeganii.icon
https://github.com/meganii/sandbox-github-actions-scheduler
🎉nishio.iconinajob.icon基素.icontakker.iconfumito.iconsta.icon
takker99/scrapbox-backupsで使わせていただいても良いですか?takker.icon
お願いします!meganii.icon
/icons/わーい.icontakker.icon
scheduleで時間実行
workflow_dispatchで手動トリガー実行
Tagとして日付を入れておけばよさそう
https://gyazo.com/25161593929578543251bcac5067a2d1
About releases - GitHub Docsによると、1つのRelaseは2GBまでだが、Release全体の容量制限はなさそう
github releaseを使う方法は考えの外だったtakker.icon
差分を見たかったので、repoに直接pushしていた
repoに入れるのと同時にreleaseでjsonを生成するのも便利そう
code:.github/workflows/scheduled-build.yml
name: Scheduled build
on:
schedule:
- cron: 0 18 * * *
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: denoland/setup-deno@v1
- name: Backup data
run: >
deno run
--allow-read
--allow-net
--allow-write
--no-check
index.ts
|と>の違いはなんでしょうか?takker.icon
yamlの仕様を見ればわかるかな?
すみません、参考元で利用していたので、安易に使っていましたmeganii.icon
|は複数行を処理するのに利用するという理解でしたが、>はとりあえず真似した感じです
要調査 調べましたmeganii.icon
ありがとうございます!takker.icon
syntax - How do I break a string in YAML over multiple lines? - Stack Overflow
>: 改行コードが無視されて、1つのコマンドとして実行
Key: >
this is my very very very
long string
this is my very very very long string\n
|: それぞれ改行コードが入るので、並べれば複数コマンド実行
Key: |
this is my very very very
long string
this is my very very very\nlong string\n
なるほど~。|が\`\`(JS)や@""(C#)などの生文字列リテラル相当の記号になるんですねtakker.icon
code:.github/workflows/scheduled-build.yml
- name: Zip
run: zip data data.json
- name: Set Date
env:
TZ: "Asia/Tokyo"
run: echo "CURRENT_DATETIME=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Release
uses: ncipollo/release-action@v1
with:
artifacts: "data.zip"
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.CURRENT_DATETIME }}
なるほど~こうやってworkflow.ymlを書くのかtakker.iconnishio.icon
利用制限に引っかかるかどうか
GitHub Terms for Additional Products and Features - GitHub Docs
cryptomining;
マイニングではない
disrupting, gaining, or attempting to gain unauthorized access to, any service, device, data, account, or network (other than those authorized by the GitHub Bug Bounty program);
非該当
the provision of a stand-alone or integrated application or service offering the Actions product or service, or any elements of the Actions product or service, for commercial purposes;
商用利用でもないので非該当
any activity that places a burden on our servers, where that burden is disproportionate to the benefits provided to users (for example, don't use Actions as a content delivery network or as part of a serverless application, but a low benefit Action could be ok if it’s also low burden); or
負担も少ないはず
if using GitHub-hosted runners, any other activity unrelated to the production, testing, deployment, or publication of the software project associated with the repository where GitHub Actions are used.
無関係ではない・・はず。
repoにもページデータをpushすれば無関係じゃなくなるtakker.icon
2022/11/27
ページごとにjsonを分割してコミットするようにしたmeganii.icon
https://github.com/meganii/sandbox-github-actions-scheduler/tree/main/villagepump/pages
takker99/scrapbox-backupsで実現していたページ単位でのcommitをGitHub Actionsで実行できるようになった
ファイル名にタイトルを使おうと思っていたが、結局ページのidを使うようにした
idとtitleの紐づけは、参照
参考
GitHub - ncipollo/release-action: An action which manages a github release
/takker/scrapbox-external-backup
/meganii/Github Actionsでbotによるアイコン付きのCommitをする方法